package com.lengxf.netty.command.impl.command_1;

import cn.hutool.json.JSONUtil;
import com.lengxf.netty.command.Command;
import com.lengxf.netty.config.message.NettyMessage;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class Command1 implements Command {

    /**
     * 返回请求
     *
     * @Author Lengxf
     */
    @Override
    public void handle(Channel channel, String param) {
        log.info("解析参数为:{}", param);
        NettyMessage nettyMessage = new NettyMessage();
        nettyMessage.setMessageType("1");
        nettyMessage.setText("收到请求并进行了回复....");
        channel.writeAndFlush(new TextWebSocketFrame(JSONUtil.toJsonStr(nettyMessage)));
    }

}
